package com.firstsource.networking.ip.tracker.data.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Entity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.firstsource.networking.ip.tracker.util.IPManipulator;

@Entity
@Table(name="dhcp_scopes")
public class DHCPScope implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="idx")
	@GeneratedValue(generator="DHCPIndexGenerator")
	@GenericGenerator(
			name="DHCPIndexGenerator",
			strategy="seqhilo",
			parameters={
					@Parameter(name="max_lo", value="1"),
					@Parameter(name="sequence", value="dhcp_idx_seq")
			}
        )
	private int idx = 0 ;

	@Column(name="description")
	private String description ;

	@Column(name="startip")
	private long startIp = 0 ;

	@Column(name="endip")
	private long endIp = 0 ;

	/**
	 * @return the idx
	 */
	public int getIdx() {
		return idx;
	}

	/**
	 * @param idx the idx to set
	 */
	public void setIdx(int idx) {
		this.idx = idx;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the startIp
	 */
	public String getStartIp() {
		return IPManipulator.long2IP(startIp);
	}

	/**
	 * @param startIp the startIp to set
	 */
	public void setStartIp(String startIp) {
		this.startIp = IPManipulator.ip2Long(startIp);
	}

	/**
	 * @return the endIp
	 */
	public String getEndIp() {
		return IPManipulator.long2IP(endIp);
	}

	/**
	 * @param endIp the endIp to set
	 */
	public void setEndIp(String endIp) {
		this.endIp = IPManipulator.ip2Long(endIp);
	}
}
